package com.gitee.feizns.quickstart.quickio.example;

import com.github.artbits.quickio.api.Collection;
import com.github.artbits.quickio.api.JDB;
import com.github.artbits.quickio.core.IOEntity;
import com.github.artbits.quickio.core.QuickIO;
import com.github.artbits.quickio.struct.Document;

import java.util.Optional;

/**
 * @author feizns
 * @since 2025/2/13
 */
public class DocumentExample {

    public static void main(String[] args) {
        try(JDB db = QuickIO.db("example_db")) {
            Collection<Document> collection = db.collection(Document.class);
//            collection.save(new Document().put("city", "Canton").put("area", 7434.4));
            Document document = collection.findOne(d -> "Canton".equals(d.get("city")));
            Optional.ofNullable(document).ifPresent(IOEntity::printJson);
        }
    }

}
